/*******************************************************************************
* 
* AudioManager create and recycle AudioSprite
*
*   !!This class is totally deprecated since XAudio crashes most of the time!!
*   Use FMOD instead
* 
******************************************************************************/
#pragma once
#include "noria.h"
#include "audio-sprite.h"

#include <xaudio2.h>
#include <atlbase.h>

namespace noria{ namespace xaudio
{
    class AudioManager
    {
    public:
        AudioManager(IXAudio2* pXAudio2);
        ~AudioManager(void);

        // ------------------------------------------------------------------------------------
        // create an instance of audio sprite
        // ------------------------------------------------------------------------------------
        unique_ptr<AudioSprite> create(cbinary_ref pcm) const;

    private:
        //CComPtr<IXAudio2> m_XAudio2;
        IXAudio2* m_XAudio2;
        IXAudio2MasteringVoice* m_master;
        
        // ------------------------------------------------------------------------------------
        // initilaize xaudio, any other call follows by this method
        //  there is no uninitialize cos ~ctor() will deal with it
        // ------------------------------------------------------------------------------------
        void init(IXAudio2* pXAudio2);
    };

}}